//引入数据库
var mongoose = require('mongoose');
var commentsSchema = new mongoose.Schema({
    userId: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "userModel"
    },
    orderId: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "order"
    },
    comments: String,
    //0-差评 1-未评论 2-好评
    status: {
        type: Number,
        default: 1
    },
    //添加时间
    admin_addTime: {
        type: Date,
        default: Date.now, //设置创建订单默认时间,传入函数
        get(val) {
            return new Date(val).toLocaleString()
        }
    },
    //评价图片
    img:{
        type:String,
        default:''
    }
});

//设置模型
commentsSchema.set('toJSON', { getters: true });

const Model = mongoose.model('commentsModel', commentsSchema, 'comments');

module.exports = Model;